const state = {
  Token: '',
  RefreshToken: '',
  isLogin: false,
  redirect: '',
  Lng: 0, // 当前经纬度
  Lat: 0,
  RealNameVerify: undefined // 是否实名
}

const mutations = {
  SET_TOKEN: (state, data) => {
    state.Token = data.Token
    state.RefreshToken = data.RefreshToken
  },
  LOGIN: (state, bool) => {
    state.isLogin = bool
  },
  SET_REDIRECT: (state, redirect) => {
    state.redirect = redirect
  },
  SET_LOCATION: (state, location) => {
    state.Lng = location.lng
    state.Lat = location.lat
  },
  SET_REALNAMEVERIFY: (state, bool) => {
    state.RealNameVerify = bool
  }
}

const actions = {
  setToken({ commit }, data) {
    commit('SET_TOKEN', data)
  },
  login({ commit }, bool) {
    commit('LOGIN', bool)
  },
  setRedirect({ commit }, redirect) {
    commit('SET_REDIRECT', redirect)
  },
  setLocation({ commit }, location) {
    commit('SET_LOCATION', location)
  },
  setRealNameVerify({ commit }, bool) {
    commit('SET_REALNAMEVERIFY', bool)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
